﻿
@model dynamic
@{
    ViewBag.Title = "患者一览";
    Layout = "~/Views/Shared/_Index.cshtml";
    var pacsHost = SiteUrl.GetUrl("OuterPacsServiceHost", "");
    //长期医嘱打印单是否显示签名
    var isShowSign = SysConfigReader.String("IS_ShowSigner");
    var curOpr = Newtouch.Common.Operator.OperatorProvider.GetCurrent();
}
<script src="~/Content/js/BootstrapMenu.min.js"></script>
<style>

    #dev_ycq {
        display: none;
    }

    #txt_cwmc {
        margin: 7px 15px;
        height: 21px;
        width: 100px;
        padding: 0 10px;
        border: 0;
        border-bottom: 1px solid #ccc;
    }

    .li-refresh {
        background-color: #00a0e9;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

        .li-refresh span {
            margin: 10px 15px;
        }

    #div_zbq {
        overflow-y: auto;
    }
    #dv_zbqleft {
        width: 99%;
    }
    .ul-zbq {
        width: 100%;
        height: 95%;
        list-style: none;
        padding: 0;
        margin: 0;
    }

        .ul-zbq li {
            margin: 25px;
            display: inline;
            float: left;
            height: 100px;
            width: 170px;
            border: 1px solid #ccc;
            border-radius: 5px 5px 0 0;
            -webkit-box-shadow: #666 3px 4px 8px;
            -moz-box-shadow: #666 3px 4px 8px;
            box-shadow: #666 3px 4px 8px;
        }

    .dv-cwmc {
        background-color: #AFEEEE;
        line-height: 25px;
        text-align: center;
        color: black;
        /*color: white;*/
        padding-left: 10px;
    }

        .dv-cwmc i {
            line-height: 25px;
            float: left;
        }

    .bedmouseover {
        background-color: #00a0e9 !important
    }

    .bedbordermouseover {
        border-color: #00a0e9 !important
    }

    .bedchoose {
        background-color: #dd4b39 !important
    }

    .bedborderchoose {
        border-color: #dd4b39 !important
    }

    .sp-leave {
        width: 20px;
        height: 20px;
        float: right;
        margin-right: 20px;
    }

    .sp-leave-1 {
        background-color: pink;
    }

    .sp-leave-2 {
        background-color: blue;
    }

    .sp-leave-3 {
        background-color: green;
    }

    .dv-patxm {
        line-height: 25px;
        padding-left: 10px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

        .dv-patxm i {
            line-height: 20px;
            width: 20px;
            color: #ffffff;
            text-align: center;
            margin-right: 10px;
        }

    .dv-doctorxm {
        line-height: 25px;
        padding-left: 10px;
    }

        .dv-doctorxm i {
            line-height: 20px;
            width: 20px;
            text-align: center;
            margin-right: 10px;
            border: 1px solid #ccc;
        }

    .dv-patType {
        line-height: 25px;
        padding-left: 10px;
    }

    .footerright {
        width: 20px;
        float: left
    }

    .ui-pg-input {
        display: inline-block;
        height: auto;
        width: auto;
        font-size: .9em;
        margin: 0;
        line-height: inherit;
        padding: 0px 0px;
        height: 20px;
        text-align: center;
        box-shadow: none;
        -webkit-box-shadow: none;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
</style>

<ul class="nav nav-tabs navb-bg" role="tablist">
    <li role="presentation" class="active" id="linkzbq">
        <a href="#div_zbq" role="tab" data-toggle="tab">在病区</a>
    </li>
    <li role="presentation" id="linkycq">
        <a href="#dev_ycq" role="tab" data-toggle="tab">已出区</a>
    </li>
    <li>
        <table class="form" style="width:460px">
            <tr>
                <td class="formValue formDdlSelectorTd">
                    <select id="sel_inpatientArea" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <td class="formValue formDdlSelectorTd" style="width:90px">
                    <select id="sel_inpatienttype" class="form-control">
                        <option value="">全部</option>
                        <option value="@ViewBag.ysgh">分管</option>
                    </select>
                </td>
                <td>
                    <input id="txt_cwmc" placeholder="输入床号" />
                </td>
                <td style="padding-left:20px;">
                    <i class="fa fa-id-card-o" title="床卡模式" style="line-height:40px" hidden></i>
                    <i class="fa fa-list" title="列表模式" style="line-height:40px"></i>
                </td>
            </tr>
        </table>
    </li>
    <li class="li-refresh" style="float: right;">
        <span class="glyphicon glyphicon-refresh" aria-hidden="true" onclick="newtouch_event_f4()"></span>
    </li>
</ul>
<div class="panel panel-default">
    <div id="div_zbq">
        @Html.Partial("_InpatientMahjongCardList")
    </div>
    <div id="dev_ycq">
        <table class="form" style="margin-left:5px;">
            <tr>
                <th class="formTitle">出区开始日期：</th>
                <td class="formValue">
                    <input id="txt_ksrq" type="text" class="form-control input-wdatepicker formClearIgnore" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" value="@DateTime.Now.ToString("yyyy-MM-01")" />
                </td>
                <th class="formTitle">结束日期：</th>
                <td class="formValue">
                    <input id="txt_jsrq" type="text" class="form-control input-wdatepicker formClearIgnore" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                </td>
                <th class="formTitle" style="width:120px">住院号/姓名/卡号：</th>
                <td class="formValue">
                    <input type="text" id="ycq_keyword" name="ycq_keyword" class="form-control" placeholder="最少1位字符" />
                </td>
                <td class="formTitle" colspan="2" style="padding-left:20px">
                    <input type="button" id="btn_search" class="btn btn-md btn-primary" value="查询" style="margin-right:10px" />
                    <input type="button" id="btn_printcq" onclick="printcq()" class="btn btn-md btn-primary" value="打印长期" style="margin-right:10px" />
                    <input type="button" id="btn_printls" onclick="printls()" class="btn btn-md btn-primary" value="打印临时" style="margin-right:10px" />
                </td>
                <td></td>
                <td></td>
            </tr>
        </table>
        <table id="div_ycqList"></table>
        <div id="div_ycqgridPager"></div>
    </div>
</div>
<script type="text/javascript">

    var isshowSign = '@isShowSign';
    $(function () {
        rows = 15;
        initinpatientList();
    });
    //**************common**************
    $('#txt_cwmc').keyup(function () {
        commonsearch();
    });
    $('#sel_inpatienttype,#sel_inpatientArea').change(function () {
        if ($(this).attr("id") == "sel_inpatientArea") {
            var $thisval = $(this).val();
            var flag = false;
            $("#sel_inpatientArea option").each(function () {
                if ($thisval == $(this).val()) {
                    flag = true;
                    localStorage.removeItem("lastabq");
                    localStorage.setItem("lastabq", $(this).val());
                }
            });
            if (!flag) {//下拉框找不到该选项就不选
                $(this).val("");
            }
        }
        commonsearch();
    });

    function initinpatientList() {
        $("#sel_inpatientArea").bindSelect({
            url: "/SystemManage/BaseData/GetAuthedWardSelectJson",
            //url: "/NurseManage/EntryRegistration/TreeViewdata",
        });

        $("#sel_inpatientArea").removeAttr("style");

        var lastbqval = localStorage.getItem("lastabq");
        var selectval = "";
        if (lastbqval == typeof (undefined) || lastbqval == "" || lastbqval == null || lastbqval == 'null') {
            if ('@ViewBag.bqval' !== "") {
                //赋值
                selectval = '@ViewBag.bqval';
            }
        } else {
            //赋值
            selectval = lastbqval;
        }
        if (selectval !== "") {
            $('#sel_inpatientArea').val(selectval).trigger("change", false);
        }
    }
    function commonsearch() {
        $(".ul-zbq").children("li").remove();
        $('.ui-pg-input').val(1);
        ajaxrequestzbq();
        ajaxrequestycq();
    }

    function newtouch_event_f4() {
        //开始时间，结束时间还原
        $('#txt_ksrq').val($.getDate());
        $('#txt_jsrq').val($.getDate());
        $('#ycq_keyword').val('');
        clearSelectpatient();//清理当前选中对象
        zbqPatientList = [];//清理病区中病人
        init();
        $('#linkzbq').addClass("active");
        $('#linkycq').removeClass("active");
        $(".nav-tabs li[id='linkzbq']").trigger("click");
    }
    //**************在病区**************

    $(function () {
        init();
        //搜索统计选项卡切换
        $(".nav-tabs li").click(function () {
            clearSelectpatient();
            if ($(this)[0].id === "linkzbq") {
                $("#div_zbq").show(300, ajaxrequestzbq);
                $("#dev_ycq").hide(500);
                $('.ul-zbq,.fa-list').show();
                $('#gbox_div_zbqList,.fa-id-card-o').hide();
                $(".ul-zbq li").each(function () {
                    if ($(this).find(".dv-cwmc").hasClass("bedchoose")) {
                        $(this).find(".dv-cwmc").removeClass("bedchoose");
                        $(this).trigger("mouseout");
                    }
                    if ($(this).hasClass("bedborderchoose")) {
                        $(this).removeClass("bedborderchoose");
                    }
                });
                //ajaxrequestzbq();
            } else if ($(this)[0].id === "linkycq") {
                $("#div_zbq").hide(500);
                $("#dev_ycq").show(300, ajaxrequestycq);
                $('.fa-id-card-o,.fa-list').hide();
                //ajaxrequestycq();
            }
        });
        $(".li-refresh").click(function () {

        });
        $("#div_zbq").height($(window).height() - 55);
        InitTZ();
    });

    function init() {
       // initzbq();
        initycq();
    }

    //**************已出区**************

    function initycq() {
        div_ycqList();

        $('#ycq_keyword').newtouchBatchFloatingSelector({
            width: 450,
            height: 200,
            caption: "选择患者",
            url: "@Url.Action("patientFloatingSelectorSource")",
            ajaxparameters: function ($thisinput) {
                var keyword = $thisinput.val().trim();
                return "keyword=" + keyword;
            },
            itemdbclickhandler: function ($thistr, $thisinput) {
                $('#ycq_keyword').val($thistr.attr('data-zyh'));
            },
            colModel: [
                { label: '主键', name: 'Id', hidden: true },
                { label: '住院号', name: 'zyh', width: 100, align: 'center' },
                { label: '病历号', name: 'blh', width: 90, align: 'center' },
                { label: '姓名', name: 'xm', width: 80, align: 'center' },
                { label: '出生年月', name: 'birth', hidden: true, width: 100, align: 'center' },
                {
                    label: '性别', name: 'xb', width: 50, align: 'center', formatter: function (cellvalue) {
                        return $.getGender(cellvalue);
                    }
                },
                { label: '年龄', name: 'birth', width: 50, align: 'center' },
                { label: '入院日期', name: 'ryrq', hidden: true }
            ]
        });
    }

    function div_ycqList() {
        $('#div_ycqList').dataGrid({
            url: "/PatientList/GetycqPatientList",
            postData: { bqCode: $('#sel_inpatientArea').val(), ys: $('#sel_inpatienttype').val(), bedCode: $('#txt_cwmc').val(), ksrq: $('#txt_ksrq').val(), jsrq: $('#txt_jsrq').val(), zyh: $('#ycq_keyword').val() },
            height: $(window).height() - 160,
            shrinkToFit: false,
            unwritten: false,
            colModel: [
                { label: 'Id', name: 'Id', hidden: true },
                { label: 'brxzdm', name: 'brxzdm', hidden: true },
                { label: 'brxzmc', name: 'brxzmc', hidden: true },
                { label: '姓名', name: 'xm', align: 'center', width: 150 },
                { label: '住院号', name: 'zyh', align: 'center', width: 80 },
                { label: '卡号', name: 'cardno', align: 'center', width: 50 },
                { label: '床号', name: 'cwmc', align: 'center', width: 80 },
                {
                    label: '性别', name: 'sex', align: 'center', width: 100, formatter: function (val) {
                        return $.getGender(val);
                    }
                },
                { label: '年龄', name: 'nlShow', align: 'center', width: 70 },
                { label: '入院诊断', name: 'zdmc', width: 80, align: 'left' },
                { label: '入院日期', name: 'ryrq', align: 'center', width: 140, formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d' } },
                { label: '出区日期', name: 'cqrq', align: 'center', width: 140, formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d' } },
                { label: '床位医生', name: 'ysmc', align: 'center', width: 120 }
            ],
            pager: "#div_ycqgridPager",
            sortname: 'cqrq desc',
            gridComplete: function () {
                //隐藏grid底部滚动条
                $("#div_ycqList").closest(".ui-jqgrid-bdiv").css({ "overflow-x": "hidden" });
            },
            onSelectRow: function (rowid) {
                var obj = $("#div_ycqList").jqGrid('getRowData', rowid);
                onSelectpatient(obj);
            }
        });
    }
    function initInpatStu() {};
    //获取已出区病人信息
    function ajaxrequestycq() {
        if (validateSearch()) {
            $('#div_ycqList').jqGrid('setGridParam', {
                url: "/PatientList/GetycqPatientList",
                postData: { bqCode: $('#sel_inpatientArea').val(), ys: $('#sel_inpatienttype').val(), bedCode: $('#txt_cwmc').val(), ksrq: $('#txt_ksrq').val(), jsrq: $('#txt_jsrq').val(), zyh: $('#ycq_keyword').val()},
                ondblClickRow: function (rowid) {
                    var obj = $("#div_ycqList").jqGrid('getRowData', rowid);
                    onSelectpatient(obj);
                    sessionStorage.setItem('currentobj', JSON.stringify(currentPatient));
                    top.top.$.Newtouchtab.tryCloseTab({ name: "医嘱管理", url: "/DoctorManage/DoctorsAdvice/Index?IsOnlyLook=true&kssj=" + $('#txt_ksrq').val() + "&ycqbr=1", AppId: "CIS"});
                    top.top.$.Newtouchtab.addTabWithOutMenu({ name: "医嘱管理", enName: "", url: "/DoctorManage/DoctorsAdvice/Index?IsOnlyLook=true&kssj=" + $('#txt_ksrq').val()+"&ycqbr=1", AppId: "CIS" });
                }
            }).trigger('reloadGrid');
            @*$.najax({
                url: "@("GetycqPatientList")",
                dataType: "json",
                data: { bqCode: $('#sel_inpatientArea').val(), ys: $('#sel_inpatienttype').val(), bedCode: $('#txt_cwmc').val(), ksrq: $('#txt_ksrq').val(), jsrq: $('#txt_jsrq').val(), zyh: $('#ycq_keyword').val() },
                type: "POST",
                success: function (respdata) {
                    $('#div_ycqList').jqGrid("clearGridData");
                    $('#div_ycqList').newtouchLocalDataGrid(null, JSON.parse(respdata.data));
                }
            });*@
        }
    }

        $('#btn_search').click(function () {
            ajaxrequestycq();
        });

        function validateSearch() {
            var bqval = $('#sel_inpatientArea').val();
            if (bqval == "") {
                $.modalAlert("病区未选择", 'warning');
                return false;
            }
            return true;
        }

        //打印长期医嘱
        function printcq() {
            var keyValue = $("#div_ycqList").jqGridRowValue().zyh;
            if (!!!keyValue) {
                $.modalAlert("未选中病人","warning");
                return;
            }
            var isSign = "0";
            if (isshowSign && isshowSign === '1') {
                isSign = "1";
            }
            top.top.$.Newtouchtab.addTabWithOutMenu({ name: zyh + "-长期医嘱", enName: "", url: "/SystemManage/YzPreView/YzPreView?zyh=" + keyValue + "&orgId=" + '@curOpr.OrganizeId' + "&isSign=" + isSign + "&yzlx=" + "长期医嘱", AppId: "EMR" });
           // window.open("/ReportManage/Report/PrintCqyzReport?zyh=" + keyValue+ "&isShowSign=" + isSign,"height=500, width=1195,top=100, left=50, toolbar =no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
        }

        //打印临时医嘱
        function printls() {
            var keyValue = $("#div_ycqList").jqGridRowValue().zyh;
            if (!!!keyValue) {
                $.modalAlert("未选中病人", "warning");
                return;
            }
            var isSign = "0";
            if (isshowSign && isshowSign === '1') {
                isSign = "1";
            }
            top.top.$.Newtouchtab.addTabWithOutMenu({ name: zyh + "-临时医嘱", enName: "", url: "/SystemManage/YzPreView/YzPreView?zyh=" + keyValue + "&orgId=" + '@curOpr.OrganizeId' + "&isSign=" + isSign + "&yzlx=" + "临时医嘱", AppId: "EMR" });
            //window.open("/ReportManage/Report/PrintLsyzReport?zyh=" + keyValue+ "&isShowSign=" + isSign, "height=500, width=1195,top=100, left=50, toolbar =no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
        }

        //右键菜单事件
        function InitTZ() {
            var menuNo = new BootstrapMenu('.ul-zbq li', {
                fetchElementData: function ($rowElem) {
                    currentobj = { "blh": $($rowElem).find(".dv-patxm").attr('data-blh'),"zyh": $($rowElem).find(".dv-patxm").attr('data-zyh'), "xm": $($rowElem).find(".dv-patxm").attr('data-xm'), "sex": $($rowElem).find(".dv-patxm").attr('data-sex'), "age": $($rowElem).find(".dv-patxm").attr('data-age'), "brxzmc": $($rowElem).find(".dv-patxm").attr('data-brxzmc'), "brxzdm": $($rowElem).find(".dv-patxm").attr('data-brxzdm'), "ryrq": $($rowElem).find(".dv-patxm").attr('data-ryrq') };
                    return currentobj;
                },
                actions: [{
                    name: '医嘱查询',
                    onClick: function (row) {
                        sessionStorage.setItem('currentobj', JSON.stringify(currentobj));
                        top.top.$.Newtouchtab.tryCloseTab({ name: "医嘱管理", url: "/DoctorManage/DoctorsAdvice/Index" });
                        top.top.$.Newtouchtab.addTabWithOutMenu({ name: "医嘱管理", enName: "", url: "/DoctorManage/DoctorsAdvice/Index" });
                    }
                },
                {
                    name: '医嘱审核',
                    onClick: function (row) {
                        sessionStorage.setItem('currentpatobj', JSON.stringify(currentobj));
                        top.top.$.Newtouchtab.tryCloseTab({ name: "医嘱审核", url: "/NurseManage/OrderAudit/Index" });
                        top.top.$.Newtouchtab.addTabWithOutMenu({ name: "医嘱审核", enName: "", url: "/NurseManage/OrderAudit/Index"});
                    }
                },
                {
                    name: '医嘱执行',
                    onClick: function (row) {
                        sessionStorage.setItem('currentpatobj', JSON.stringify(currentobj));
                        top.top.$.Newtouchtab.tryCloseTab({ name: "医嘱执行", url: "/NurseManage/OrderExecution/Index" });
                        top.top.$.Newtouchtab.addTabWithOutMenu({ name: "医嘱执行", enName: "", url: "/NurseManage/OrderExecution/Index" });
                    }
                },
                {
                    name: '三测单查询',
                    onClick: function (row) {
                        sessionStorage.setItem('currentpatobj', JSON.stringify(currentobj));
                        top.top.$.Newtouchtab.tryCloseTab({ name: "三测单查询", url: "/NurseManage/InpatientVitalSigns/TemperatureChartIndex" });
                        top.top.$.Newtouchtab.addTabWithOutMenu({ name: "三测单查询", enName: "", url: "/NurseManage/InpatientVitalSigns/TemperatureChartIndex" });
                    }
                }, {
                    name: '护理录入',
                    onClick: function (row) {
                        sessionStorage.setItem('currentpatobj', JSON.stringify(currentobj));
                        top.top.$.Newtouchtab.tryCloseTab({ name: "护理录入", url: "/NurseManage/InpatientVitalSigns/QueryIndex" });
                        top.top.$.Newtouchtab.addTabWithOutMenu({ name: "护理录入", enName: "", url: "/NurseManage/InpatientVitalSigns/QueryIndex" });
                    }
                }, {
                    name: 'LIS报告',
                    onClick: function (row) {
                         //金风易通 LIS 2024-4-28 chl
                        window.open("@pacsHost/doctor-api/api/viewer?type=1&pid=" + currentobj.blh + "&areaCode=" + "@curOpr.OrganizeId", "_blank");
                        //测试链接
                        //window.open("@pacsHost/doctor-api/api/viewer?type=1&pid=JF566&areaCode=6d5752a7-234a-403e-aa1c-df8b45d3469f", "_blank");

                        //$.modalOpen({
                        //    id: "medicaljyForm",
                        //    title: "LIS检验申请单列表",
                        //    url: "/MedicalRecord/LisSqdhQueryForm?mzzyh=" + currentobj.zyh + "&type=" + "zy",
                        //    width: "900px",
                        //    height: "600px",
                        //    btn: ['', '关闭'],
                        //    btnclass: ['', 'btn btn-danger'],
                        //});
                    }
                }
                , {
                    name: 'PASC报告',
                    onClick: function (row) {
                        //金风易通 PACS 2024-4-28 chl
                        window.open("@pacsHost/doctor-api/api/viewer?type=2&pid=" + currentobj.blh + "&areaCode=" + "@curOpr.OrganizeId", "_blank");
                        //测试链接
                        //window.open("@pacsHost/doctor-api/api/viewer?type=2&pid=1034097&areaCode=6d5752a7-234a-403e-aa1c-df8b45d3469f", "_blank");

                        //$.modalOpen({
                        //    id: "medicaljyForm",
                        //    title: "PASC检查申请单列表",
                        //    url: "/MedicalRecord/PacsSqdhQueryForm?mzzyh=" + currentobj.zyh + "&type=" + "zy",
                        //    width: "800px",
                        //    height: "500px",
                        //    btn: ['', '关闭'],
                        //    btnclass: ['', 'btn btn-danger'],
                        //});
                    }
                }
                , {
                    name: '患者出区',
                    onClick: function (row) {
                        $.modalConfirm("确定出区？", function (flag) {
                            if (flag) {
                                $.modalOpen({
                                    id: "OutAreaForm",
                                    title: "患者出区",
                                    url: "/NurseManage/WardMaintenance/OutAreaForm?zyh=" + currentobj.zyh,
                                    width: "500px",
                                    height: "480px",
                                    callBack: function (iframeId) {
                                        $.currentWindow(iframeId).AcceptClick(function () {
                                            $.loading(false);
                                            $.modalClose("OutAreaForm");
                                        });
                                    }
                                });
                            }
                        });
                    }
                }
                ]
            });
        }
</script>